"""
ASGI config for djangoProject1 project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
# TODO websocket
from index.routing import websocket_urlpatterns  # 直接导入 WebSocket 路由

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoProject1.settings')

application = ProtocolTypeRouter({
    "http": get_asgi_application(),  # 处理 HTTP 请求
    "websocket": AuthMiddlewareStack(
        URLRouter(
            websocket_urlpatterns  # 确保 WebSocket 路由被正确引入
        )
    ),
})

